// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import { battle_actionType } from "../common/common_enum";

const {ccclass, property} = cc._decorator;

@ccclass
export default class actionList extends cc.Component {

    @property(cc.Node) 
    m_actionNode: cc.Node = null;
    actionList = [];

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    addAction(act:battle_actionType){
        this.actionList.push(act);
        let n_node = cc.instantiate(this.m_actionNode);
        n_node.active = true;
        let color = cc.Color.WHITE;
        switch (act) {
            case battle_actionType.red:
                color = cc.Color.RED;
                break;
            case battle_actionType.green:
                color = cc.Color.GREEN;
                break;
                
            case battle_actionType.blue:
                color = cc.Color.BLUE;
                break;
            default:
                break;
        }
        n_node.y = 0;
        n_node.color = color;
        this.node.addChild(n_node)
    }

    removeAction(){
        this.node.removeAllChildren();
    }

    start () {

    }

    // update (dt) {}
}
